from PIL import Image
import os
import cv2 
import glob

index = "8-s196"
# image_dir = f"./logs_brats/save_plots_2/{index}/colord/"
image_dir = f"./logs_liver/diffusion_saveplots/{index}/colord/"
all_paths = glob.glob(f"{image_dir}*.png")

save_dir = f"./logs_liver/diffusion_saveplots/{index}/handled/"
os.makedirs(save_dir, exist_ok=True)

image_path = f"./logs_liver/diffusion_saveplots/{index}/image.png"
for p in all_paths:
    f_name = p.split("/")[-1]
    image_path_i = cv2.imread(image_path)
    cur_path_i = cv2.imread(p)
    dst = cv2.addWeighted(image_path_i, 0.8, cur_path_i, 0.6, 0.0)
    
    cv2.imwrite(os.path.join(save_dir, f"{f_name}_weight.png"), dst)